package com.zhuiyun.pm.client.order.service.servicelmpl;

import com.zhuiyun.pm.client.order.entity.ClientOrder;
import com.zhuiyun.pm.client.order.mapper.OrderMapper;
import com.zhuiyun.pm.client.order.service.OrderService;
import com.zhuiyun.pm.config.CommonResult;
import com.zhuiyun.pm.sys.order.entity.SysOrderEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @ClassName AddressServicelmpl
 * Description 发布service实现
 * Author Administrator
 * @Date 2023/3/14
 * Version 1.0
 **/
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    OrderMapper orderMapper;

    /**
     * 查询全部订单
     * @author 温
     * @date 2023/3/15 10:02
     * @parameter [clientOrder]
     * @return java.util.List<com.zhuiyun.pm.client.dingdan.entity.ClientOrder>
     */
    @Override
    public List<ClientOrder> orderListInfo(ClientOrder clientOrder) {
        clientOrder.setDelFlag(0);
        List<ClientOrder> clientOrders = orderMapper.select(clientOrder);
        return clientOrders;
    }

  /**
   * 两表连查查询每个订单详细地址
   * @author 温
   * @date 2023/3/17 14:21
   * @parameter [id]
   * @return com.zhuiyun.pm.client.order.entity.ClientOrder
   */
    @Override
    public ClientOrder clientList(int id){
        ClientOrder clientOrders = orderMapper.clientList(id);
        return clientOrders;
    }


/**订单详情
 * @Author 温
 * @Description //TODO
 * @Date 19:25 2023/3/16
 **/
    @Override
    public ClientOrder clientOrder( int id) {
        ClientOrder clientOrder = orderMapper.selectByPrimaryKey(id);
        return clientOrder;
    }


    /**
     * 点击立即付款  到 待发货中
     * @author 温
     * @date 2023/3/15 10:20改变订单状态为2
     * @parameter [id]
     * @return com.zhuiyun.pm.config.CommonResult
     */
    @Override
    public CommonResult clientPaid(int id) {
        ClientOrder clientOrder = new ClientOrder();
        clientOrder.setId(id);
        clientOrder.setOrderFlag(2);
        int i = orderMapper.updateByPrimaryKeySelective(clientOrder);
        return CommonResult.ok(i);
    }
    /**
     *  订单状态2点击立即付款 改变订单状态为3 到 待收货中
     * @author 温
     * @date 2023/3/15 10:20
     * @parameter [id]
     * @return com.zhuiyun.pm.config.CommonResult
     */
    @Override
    public CommonResult clientCrops(int id) {
        ClientOrder clientOrder = new ClientOrder();
        clientOrder.setId(id);
        clientOrder.setOrderFlag(3);
        int i = orderMapper.updateByPrimaryKeySelective(clientOrder);
        return CommonResult.ok(i);
    }
/**
 * 订单状态3点击收货完成 改变订单状态为4 到 已完成
 * @author 温
 * @date 2023/3/15 11:50
 * @parameter [id]
 * @return com.zhuiyun.pm.config.CommonResult
 */
    @Override
    public CommonResult clientGoods(int id) {
        ClientOrder clientOrder = new ClientOrder();
        clientOrder.setId(id);
        clientOrder.setOrderFlag(4);
        int i = orderMapper.updateByPrimaryKeySelective(clientOrder);
        return CommonResult.ok(i);
    }



    /**\两表连查查询每个订单地址信息
     *
     * @param clientOrder
     * @return
     */
//    @Override
//    public List<ClientOrder> ClientList(ClientOrder clientOrder) {
//        List<ClientOrder> clientOrders = orderMapper.ClientList(clientOrder);
//        return clientOrders;
//    }
}
